<!--
 * @description  : 案件基本信息
 * @descriptionDetail: 案件基本信息
 * @copyright    : 广西烟草
 * @author       : wmb
 * @create       : 2022-07-09 18:43:02
-->
<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar
      :is-white="false"
      :title="navTitle"
      :custom-back="goBack"
      style="z-index: 99999"
    ></theme-navbar>
    <!-- #endif -->
    <view
      class="content content-bg ifn-content"
      style="background-color: white"
    >
      <form-section title="基本信息"></form-section>
      <u-form
        class="u-form-m"
        :model="baseInfo"
        :error-type="['border-bottom', 'message']"
        label-width="auto"
        label-position="top"
        ref="uForm"
      >
        <u-form-item label="案件编号">
          <u-input :disabled="true" placeholder="" v-model="baseInfo.caseCode">
          </u-input>
        </u-form-item>
        <u-form-item
          label="案发时间"
          prop="caseDate"
          :required="true"
          right-icon="arrow-right"
        >
          <u-input
            :disabled="true"
            placeholder="请选择案发时间"
            v-model="baseInfo.caseDate"
            @click="!justView && selectCaseDate()"
          >
          </u-input>
        </u-form-item>
        <u-form-item label="案值">
          <u-input
            :disabled="true"
            placeholder="0"
            v-model="baseInfo.caseTotalVal"
          >
          </u-input>
          <text style="margin-left: 20rpx"> 元 </text>
        </u-form-item>
        <u-form-item label="涉案金额"
                     prop="involvedAmt"
        >
          <u-input
              placeholder="0"
              v-model="baseInfo.involvedAmt"
          >
          </u-input>
          <text style="margin-left: 20rpx"> 元 </text>
        </u-form-item>
        <u-form-item
          label="案由"
          prop="caseOfAction"
          :required="true"
          right-icon="arrow-right"
        >
          <u-input
            :disabled="true"
            placeholder="请选择"
            v-model="baseInfo.caseOfAction"
            @click="!justView && choiceCaseOfAction()"
          ></u-input>
        </u-form-item>
        <u-form-item prop="placeGis" :required="true" label="GIS 经纬度">
          <!-- placeGisX placeGisY -->
          <u-input
            placeholder="请选择"
            :disabled="true"
            v-model="baseInfo.placeGis"
          >
          </u-input>
          <u-icon
            name="map-fill"
            :color="$theme.u_type_primary"
            size="44"
            @click="!justView && getLocation()"
          ></u-icon>
        </u-form-item>
        <u-form-item label="案发地址" prop="placeStreet" :required="true">
          <view style="display: flex; flex-direction: column; width: 100%">
            <!-- <view  style="display: inline-flex;flex-direction: row;align-items: center;"> -->
            <u-input
              type="select"
              :disabled="true"
              placeholder="案发地行政区划选择"
              v-model="areaCoinNames"
              @click="!justView && (nativeNameSelectShow = true)"
            ></u-input>
            <!-- <u-icon :size="$theme.cm_form_right_icon_size" style="flex-shrink: 0;margin-left: 10rpx;" :color="$theme.cm_form_right_icon_color" name="arrow-right"></u-icon> -->
            <!-- </view> -->
            <u-line
              :color="$theme.u_border_color"
              style="margin: 10rpx 0"
            ></u-line>
            <u-row gutter="16">
              <u-col span="12">
                <u-input
                  :disabled="justView"
                  :maxlength="50"
                  :border="true"
                  placeholder="详细地址"
                  v-model="baseInfo.placeStreet"
                ></u-input>
              </u-col>
            </u-row>
          </view>
        </u-form-item>
        <u-form-item
          prop="marketName"
          label="集贸市场名称"
          v-show="baseInfo.handleProc == CASE_TYPE.NORMAL"
        >
          <u-input
            :disabled="justView"
            placeholder="案发地点为集贸市场时填写"
            v-model="baseInfo.marketName"
          ></u-input>
        </u-form-item>
        <u-form-item
          label="案件来源"
          required
          prop="caseSourceName"
          :rightIcon="justView ? '' : 'arrow-right'"
          v-if="baseInfo.handleProc == CASE_TYPE.NORMAL"
        >
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.CASE_SOURCE"
            :dicCode="baseInfo.caseSource"
            :border="false"
            type="text"
            :select-open="
              dicSelectOpen('caseSource', $u.dic.DIC_KEYS.CASE_SOURCE)
            "
            placeholder="请选择"
            :disabled="true"
            v-model="baseInfo.caseSourceName"
            @changeInputModelData="
              (name) => {
                $set(baseInfo, 'caseSourceName', name);
              }
            "
            @click="
              showDic(
                $u.dic.DIC_KEYS.CASE_SOURCE,
                baseInfo.caseSource,
                'caseSource'
              )
            "
          />
        </u-form-item>
        <u-form-item
          label="举报形式"
          v-if="baseInfo.caseSource == CASE_SOURCE.reportRecord"
          prop="reportTypeName"
        >
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.C_REPORT_TYPE"
            :dicCode="baseInfo.reportType"
            :border="false"
            type="select"
            :select-open="
              dicSelectOpen('reportType', $u.dic.DIC_KEYS.C_REPORT_TYPE)
            "
            placeholder="请选择"
            :disabled="true"
            v-model="baseInfo.reportTypeName"
            @changeInputModelData="
              (name) => {
                $set(baseInfo, 'reportTypeName', name);
              }
            "
            @click="
              false &&
                showDic(
                  $u.dic.DIC_KEYS.C_REPORT_TYPE,
                  baseInfo.reportType,
                  'reportType'
                )
            "
          />
        </u-form-item>
        <u-form-item
          label="移送来源"
          v-if="baseInfo.caseSource == CASE_SOURCE.transIn"
          prop="transSourceName"
        >
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.C_TRANS_SOURCE"
            :dicCode="baseInfo.transSource"
            :border="false"
            type="select"
            :select-open="
              dicSelectOpen('transSource', $u.dic.DIC_KEYS.C_TRANS_SOURCE)
            "
            placeholder="请选择"
            :disabled="true"
            v-model="baseInfo.transSourceName"
            @changeInputModelData="
              (name) => {
                $set(baseInfo, 'transSourceName', name);
              }
            "
            @click="
              false &&
                showDic(
                  $u.dic.DIC_KEYS.C_TRANS_SOURCE,
                  baseInfo.transSource,
                  'transSource'
                )
            "
          />
        </u-form-item>
        <u-form-item
          label="证据类型"
          :rightIcon="justView ? '' : 'arrow-right'"
          v-if="baseInfo.handleProc == CASE_TYPE.NORMAL"
        >
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.EVID_TYPE"
            :dicCode="baseInfo.evidTypeCode"
            :border="false"
            type="text"
            :select-open="
              dicMultiSelectOpen('evidTypeCode', $u.dic.DIC_KEYS.EVID_TYPE)
            "
            placeholder="请选择"
            :disabled="true"
            v-model="baseInfo.evidType"
            @changeInputModelData="
              (name) => {
                $set(baseInfo, 'evidType', name);
              }
            "
            @click="
              showMultiDic(
                $u.dic.DIC_KEYS.EVID_TYPE,
                baseInfo.evidTypeCode,
                'evidTypeCode'
              )
            "
          />
        </u-form-item>
        <u-form-item
          label="查获环节"
          required
          prop="getNodeStr"
          :rightIcon="justView ? '' : 'arrow-right'"
          v-if="baseInfo.handleProc == CASE_TYPE.NORMAL"
        >
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.GET_NODE"
            :dicCode="baseInfo.getNode"
            :border="false"
            type="text"
            :select-open="
              dicMultiSelectOpen('getNode', $u.dic.DIC_KEYS.GET_NODE)
            "
            placeholder="请选择"
            :disabled="true"
            v-model="baseInfo.getNodeStr"
            :needValid="true"
            @changeInputModelData="
              (name) => {
                $set(baseInfo, 'getNodeStr', name);
              }
            "
            @click="
              showMultiDic(
                $u.dic.DIC_KEYS.GET_NODE,
                baseInfo.getNode,
                'getNode'
              )
            "
          />
        </u-form-item>
        <u-form-item
          label="案件来源地"
          class="caseFromClass"
          v-if="baseInfo.handleProc == CASE_TYPE.NORMAL"
        >
          <auto-input
            tplClass="tp-class"
            :disabled="justView"
            absIndex="1"
            :searchData="searchData"
            absClass="caseFromClass"
            placeholder="请输入来源地"
            v-model="baseInfo.caseFrom"
            @choiceAutoItem="choiceAutoItem"
          >
          </auto-input>
        </u-form-item>
        <u-form-item
          label="案件去向地"
          class="caseToClass"
          v-if="baseInfo.handleProc == CASE_TYPE.NORMAL"
        >
          <auto-input
            tplClass="tp-class"
            :disabled="justView"
            absIndex="2"
            :searchData="searchData"
            absClass="caseToClass"
            placeholder="请输入去向地"
            v-model="baseInfo.caseTo"
            @choiceAutoItem="choiceAutoItem"
          >
          </auto-input>
        </u-form-item>
        <u-form-item
          label="是否互联网案件"
          label-position="left"
          v-if="baseInfo.handleProc == CASE_TYPE.NORMAL"
        >
          <view class="market_cs">
            <u-switch
              :disabled="justView"
              v-model="baseInfo.isInternetCase"
            ></u-switch>
          </view>
        </u-form-item>
        <u-form-item
          label-width="auto"
          prop="isReportHotline"
          required
          label="是否12313转办"
          label-position="left"
        >
          <view class="market_cs">
            <u-switch
              :disabled="justView"
              v-model="baseInfo.isReportHotline"
              @change="hotlineChange"
            ></u-switch>
          </view>
        </u-form-item>
        <u-form-item
          label="受理单号"
          v-if="baseInfo.isReportHotline"
          :required="baseInfo.isReportHotline"
          prop="applyCode"
        >
          <u-input
            placeholder="请填写受理单号"
            v-model="baseInfo.applyCode"
          ></u-input>
        </u-form-item>
        <u-form-item
          label-width="auto"
          required
          label="是否专项行动"
          label-position="left"
        >
          <view class="market_cs">
            <u-switch
              :disabled="justView"
              v-model="baseInfo.isActionResult"
              @change="actionChange"
            ></u-switch>
          </view>
        </u-form-item>
        <u-form-item
          v-if="baseInfo.isActionResult"
          required
          label="关联专项行动"
          :label-width="220"
          right-icon="arrow-right"
          prop="actionResultName"
        >
          <u-input
            placeholder="请选择关联专项行动"
            :needValid="true"
            :disabled="true"
            v-model="baseInfo.actionResultName"
            @tap="!justView && addActionRelation()"
          />
        </u-form-item>
        <u-form-item
            label-width="auto"
            label="是否影响区域销量"
            label-position="left"
        >
          <view class="market_cs">
            <u-switch
                v-model="baseInfo.isAffectRegionalSales"
            ></u-switch>
          </view>
        </u-form-item>
        <u-form-item
            label-width="auto"
            label="是否散支烟案件"
            label-position="left"
        >
          <view class="market_cs">
            <u-switch
                v-model="baseInfo.isLooseCigaretteCase"
            ></u-switch>
          </view>
        </u-form-item>
        <u-form-item
          label="案情摘要"
          v-if="baseInfo.handleProc == CASE_TYPE.NORMAL"
        >
          <u-input
            :disabled="justView"
            type="textarea"
            placeholder="请输入"
            v-model="baseInfo.caseBrief"
          ></u-input>
        </u-form-item>
        <u-gap
          :marginRight="getGapMarginRowNumber()"
          :marginLeft="getGapMarginRowNumber()"
          :height="$theme.cm_gap_height"
          :bg-color="$theme.cm_gap_color"
        ></u-gap>
        <form-section title="承办信息"></form-section>
        <u-form-item
          label="承办人"
          prop="undertakerUuid"
          :required="true"
          right-icon="arrow-right"
        >
          <u-input
            :disabled="true"
            placeholder="请选择"
            v-model="baseInfo.undertaker"
            @click="!justView && choiceUnderTaker()"
          ></u-input>
        </u-form-item>
        <u-form-item
          prop="checkerUuid"
          label="案审员(不少于2人)"
          right-icon="arrow-right"
        >
          <u-input
            :disabled="true"
            placeholder="请选择"
            v-model="baseInfo.checker"
            @click="!justView && choiceChecker()"
          ></u-input>
        </u-form-item>
        <u-form-item
          label="承办部门"
          prop="regDeptUuid"
          :required="true"
          right-icon="arrow-right"
        >
          <u-input
            :disabled="true"
            placeholder="请选择"
            v-model="baseInfo.regDeptName"
            @click="!justView && (orgSelectShow = true)"
          >
          </u-input>
        </u-form-item>
      </u-form>
      <u-picker
        mode="time"
        :params="pickerParams"
        v-model="showPickerYear"
        @confirm="pickerConfirm"
      ></u-picker>
    </view>
    <view class="submit-btns btn-other-cls" v-if="!justView">
      <u-button class="u-btn" type="primary" @click="submit"> 保存 </u-button>
    </view>
    <!-- 行政区划选择 -->
    <u-popup mode="bottom" height="80%" v-model="nativeNameSelectShow">
      <area-select @choose="nativeNameSelectShowComfir"></area-select>
    </u-popup>
    <!-- 下拉选择用 -->
    <dic-choice
      :keyWord="dicKeyWords"
      :currentSelect="dicCurrentSelect"
      v-model="dicShow"
      @confirm="selectDicConfirm"
    ></dic-choice>
    <!-- 案审选择 -->
    <u-popup mode="bottom" height="80%" v-model="orgPersonSelectShow">
      <user-tree
        treeType="zm-case"
        :roleCodes="roleCodes"
        @choose="handlerChoosePerson"
      >
      </user-tree>
    </u-popup>
    <!-- 组织机构选择 -->
    <u-popup mode="bottom" height="80%" v-model="orgSelectShow">
      <org-select
        :isHybrid="true"
        limitNodeType="all"
        treeType="zm-case"
        @choose="handlerChooseOrg"
      ></org-select>
    </u-popup>
    <!-- 多选字典组件 -->
    <u-popup mode="bottom" height="50%" v-model="mulitChoiceShow">
      <dic-multi-choice
        :keyWord="dicKeyWords"
        :defaultUids="dicCurrentSelect"
        @select="multiChoiceConfirm"
      ></dic-multi-choice>
    </u-popup>
  </view>
</template>

<script>
import areaSelect from "@/components/area-select.vue";
import DicChoice from "@/components/dic_choice.vue";
import UserTree from "@/components/user-tree.vue";
import DicInput from "@/components/dic_input.vue";
import DicMultiChoice from "@/components/dic_multi_choice.vue";
import OrgSelect from "@/components/org-select.vue";
import caseService from "@/service/case/case.service";
import commonService from "@/service/common/common.service";
import AutoInput from "@/components/autoInput.vue";
import FormSection from "@/components/form-section.vue";
import { v4 as uuidv4 } from "uuid";
import {
  CASE_TYPE,
  PARTY_TYPE_CODE,
  CASE_SOURCE,
  C_REPORT_TYPE,
  C_TRANS_SOURCE,
} from "@/service/case/mapping/index.js";
export default {
  components: {
    areaSelect,
    DicChoice,
    DicInput,
    UserTree,
    OrgSelect,
    DicMultiChoice,
    AutoInput,
    FormSection,
  },
  onLoad() {
    let param = this.getRouteParam();
    if (!param) param = {};
    this.objMerge(this.baseInfo, param);
    console.log(this.baseInfo);
    if (this.baseInfo.involvedAmt === "" || !this.baseInfo.involvedAmt) {
      this.baseInfo.involvedAmt = this.baseInfo.caseTotalVal;
    }
    if (
      this.baseInfo.caseSource == CASE_SOURCE.reportRecord ||
      this.baseInfo.caseSource == CASE_SOURCE.transIn
    ) {
      this.status = true;
    }
  },
  data() {
    return {
      CASE_TYPE,
      PARTY_TYPE_CODE,
      CASE_SOURCE,
      user: this.$storage.get(this.$rp.common.USER),
      dicKeyWords: "",
      dicCurrentSelect: "",
      dicShow: false,
      orgSelectShow: false,
      mulitChoiceShow: false,
      orgPersonSelectShow: false,
      checkOrUnderTaker: false, // false 表示checker  true 表示 underTaker
      dicType: "",
      rightIconStyle: {
        fontSize: "40rpx",
        color: this.$theme.u_type_primary,
      },
      nativeNameSelectShow: false,
      showPickerYear: false,
      pickerParams: {
        year: true,
        month: true,
        day: true,
        hour: true,
        minute: true,
        second: true,
      },
      areaCoinNames: "",
      baseInfo: {
        isInternetCase: false,
        casePlace: "",
        caseOfAction: "",
        placeGis: "",
        marketName: "",
        placeProvCode: "",
        placeCityCode: "",
        placeCountyCode: "",
        placeStreet: "",
        caseDate: this.$u.timeFormat(Date.now(), "yyyy-mm-dd hh:MM:ss"),
        applyCode: "",
        actionUuid: "",
        isAffectRegionalSales: false,
        isLooseCigaretteCase: false,
        involvedAmt: ""
      },
      hasMarket: false,
      rules: {
        involvedAmt: [
          {
            validator: (rule, value, callback) => {
              if (!this.baseInfo.caseTotalVal) {
                callback()
              }
              if (this.baseInfo.caseTotalVal) {
                if (isNaN(value)) {
                  return callback(new Error("请输入数字"));
                }
                if (value < this.baseInfo.caseTotalVal) {
                  return callback(new Error("涉案金额不能小于案值"));
                }
              }

              callback(); // 如果验证通过，调用callback函数
            },
            // 可以单个或者同时写两个触发验证方式
            trigger: ["change", "blur"],
          }
        ],
        caseOfAction: [
          {
            required: true,
            message: "请输入案由",
            // 可以单个或者同时写两个触发验证方式
            trigger: ["change", "blur"],
          },
        ],
        caseDate: [
          {
            required: true,
            message: "请选择案发时间",
            // 可以单个或者同时写两个触发验证方式
            trigger: ["change", "blur"],
          },
        ],
        placeGis: [
          {
            required: true,
            message: "请选择GIS经纬度",
            // 可以单个或者同时写两个触发验证方式
            trigger: ["change", "blur"],
          },
        ],
        areaCoinNames: [
          {
            required: true,
            message: "请选择行政区划",
            // 可以单个或者同时写两个触发验证方式
            trigger: ["change", "blur"],
          },
        ],
        placeStreet: [
          {
            required: true,
            message: "请输入详细地址",
            // 可以单个或者同时写两个触发验证方式
            trigger: ["blur"],
          },
        ],
        undertakerUuid: [
          {
            required: true,
            message: "请选择承办人",
            // 可以单个或者同时写两个触发验证方式
            trigger: ["change", "blur"],
          },
        ],
        regDeptUuid: [
          {
            required: true,
            message: "请选择承办部门",
            // 可以单个或者同时写两个触发验证方式
            trigger: ["change", "blur"],
          },
        ],
        caseFrom: [
          {
            // 自定义验证函数，见上说明
            validator: (rule, value, callback) => {
              if (this.baseInfo.handleProc != "1" || !this.isTransCase)
                return true;
              return !this.$u.test.isEmpty(value);
            },
            message: "来源地不能为空",
            // 触发器可以同时用blur和change
            trigger: ["change", "blur"],
          },
        ],
        caseTo: [
          {
            // 自定义验证函数，见上说明
            validator: (rule, value, callback) => {
              if (this.baseInfo.handleProc != "1" || !this.isTransCase)
                return true;
              return !this.$u.test.isEmpty(value);
            },
            message: "去向地不能为空",
            // 触发器可以同时用blur和change
            trigger: ["change", "blur"],
          },
        ],
        actionResultName: [
          {
            required: true,
            message: "请选择关联专项行动",
            trigger: ["change", "blur"],
          },
        ],
        caseSourceName: [
          {
            required: true,
            message: "请选择案件来源",
            trigger: ["change", "blur"],
          },
        ],
        getNodeStr: [
          {
            required: true,
            message: "请选择查获环节",
            trigger: ["change", "blur"],
          },
        ],
        applyCode: [
          {
            required: true,
            message: "请填写受理单号",
            trigger: ["change", "blur"],
          },
        ],
      },
      isTransCase: false, // 默认不是无证运输案件
      status: false,
      roleCodes: "", // 承办： s_zmjcy_x,s_zmjcy_s    案审人: s_ajsly_s,s_ajsly_x
    };
  },
  // 必须要在onReady生命周期，因为onLoad生命周期组件可能尚未创建完毕
  onReady() {
    this.$refs.uForm.setRules(this.rules);
  },
  computed: {
    justView() {
      try {
        // this.baseInfo.from == 'check' || this.baseInfo.from == 'areasCheck' ||
        if (
          this.baseInfo.from == "searchKey" ||
          this.baseInfo.from == "intelligence"
        ) {
          return true;
        } else {
          let ar = this.baseInfo.isLookList;
          if (this.baseInfo.handleProc == CASE_TYPE.NORMAL) {
            return ar[0] == "0";
          } else {
            return false;
          }
        }
      } catch (e) {
        console.log(e);
        return false;
      }
    },
    transport() {
      if (
        this.baseInfo.getNodeStr &&
        this.baseInfo.getNodeStr.indexOf("运输") != -1
      ) {
        return true;
      } else {
        return false;
      }
    },
  },
  watch: {},
  mounted() {
    this.init();
  },
  methods: {
    init() {
      let self = this;
      if (
        !this.$u.test.isEmpty(this.baseInfo.placeProvCode) &&
        !this.$modal.isMuniCity(this.baseInfo.placeProvCode)
      ) {
        this.areaCoinNames =
          commonService.getPersonLocal(this.baseInfo.placeProvCode, true)
            .areaName || "";
      }
      if (!this.$u.test.isEmpty(this.baseInfo.placeCityCode)) {
        this.areaCoinNames +=
          commonService.getPersonLocal(this.baseInfo.placeCityCode, true)
            .areaName || "";
      }
      if (!this.$u.test.isEmpty(this.baseInfo.placeCountyCode)) {
        this.areaCoinNames +=
          commonService.getPersonLocal(this.baseInfo.placeCountyCode, true)
            .areaName || "";
      }
      if (this.$u.test.isEmpty(this.baseInfo.placeProvCode)) {
        commonService
          .queryAreaBaseByCode(this.user.user.org.orgUuid)
          .then((res) => {
            if (res.success && res.bean) {
              console.log(res.bean);
              if (this.$modal.isMuniCity(res.bean.procode)) {
                this.areaCoinNames = [
                  res.bean.admdivname,
                  res.bean.countryname,
                ].join("");
              } else {
                this.areaCoinNames = [
                  res.bean.proname,
                  res.bean.admdivname,
                  res.bean.countryname,
                ].join("");
              }
              this.baseInfo.placeProvCode = res.bean.procode;
              this.baseInfo.placeCityCode = res.bean.admdivcode;
              this.baseInfo.placeCountyCode = res.bean.countrycode;
            }
          })
          .catch((e) => {
            console.log(e);
          });
      }
      if (!this.$u.test.isEmpty(this.baseInfo.placeGisX)) {
        this.baseInfo.placeGis = `${this.baseInfo.placeGisX},${this.baseInfo.placeGisY}`;
      }
    },
    hotlineChange(e) {
      if (!e) {
        this.baseInfo.applyCode = "";
      }
    },
    handlerChooseOrg(orgs) {
      this.baseInfo.regDeptUuid = orgs[0].id;
      this.baseInfo.regDeptName = orgs[0].name;
      this.orgSelectShow = false;
    },
    multiChoiceConfirm(e) {
      this.mulitChoiceShow = false;
      let labels = [];
      let codes = [];
      e.forEach((itm) => {
        labels.push(itm.bcbName);
        codes.push(itm.bcbCode);
      });
      if (this.dicKeyWords == this.$u.dic.DIC_KEYS.TOBACCO_GOODS_TYPE) {
        // 未办证原因
        this.baseInfo.relateTobaccoGoodsName = labels.join(",");
        this.baseInfo.relateTobaccoGoods = codes.join(",");
      } else if (this.dicKeyWords == this.$u.dic.DIC_KEYS.EVID_TYPE) {
        // 未办证原因
        this.baseInfo.evidType = labels.join(",");
        this.baseInfo.evidTypeCode = codes.join(",");
      } else if (this.dicKeyWords == this.$u.dic.DIC_KEYS.GET_NODE) {
        // 未办证原因
        this.baseInfo.getNodeStr = labels.join(",");
        this.baseInfo.getNode = codes.join(",");
        if (this.baseInfo.getNodeStr.indexOf("运输") != -1) {
          this.baseInfo.isTransport = true;
        }
      }
    },
    getGapMarginRowNumber() {
      return "-" + this.$theme.cm_content_paddng_row.replace("rpx", "");
    },
    selectDicConfirm(e) {
      if (this.dicKeyWords == this.$u.dic.DIC_KEYS.CASE_SOURCE) {
        // 未办证原因
        this.baseInfo.caseSourceName = e[0].label;
        this.baseInfo.caseSource = e[0].extra.bcbCode;
        if (e[0].extra.bcbCode == CASE_SOURCE.reportRecord) {
          // 举报01
          this.baseInfo.reportTypeName = C_REPORT_TYPE.COMPLAINTS_CN;
          this.baseInfo.reportType = C_REPORT_TYPE.COMPLAINTS;
        } else if (e[0].extra.bcbCode == CASE_SOURCE.transIn) {
          // 案件移交03
          this.baseInfo.transSourceName = C_TRANS_SOURCE.OUT_INDUSTRY_CN;
          this.baseInfo.transSource = C_TRANS_SOURCE.OUT_INDUSTRY;
        } else {
          this.baseInfo.reportTypeName = "";
          this.baseInfo.reportType = "";
          this.baseInfo.transSourceName = "";
          this.baseInfo.transSource = "";
        }
      }
    },
    showDic(key, cur, type) {
      if (key == this.$u.dic.DIC_KEYS.CASE_SOURCE && this.status == true)
        return;
      if (this.dicShow) return;
      this.dicKeyWords = key;
      this.dicCurrentSelect = cur;
      this.dicShow = true;
      this.dicType = type;
    },
    showMultiDic(key, cur, type) {
      if (this.mulitChoiceShow) return;
      this.dicKeyWords = key;
      this.dicCurrentSelect = cur;
      this.mulitChoiceShow = true;
      this.dicType = type;
    },
    dicSelectOpen(type, keyWords) {
      if (type == this.dicType) {
        if (this.dicKeyWords == keyWords && this.dicShow) {
          return true;
        }
        return false;
      }
    },
    dicMultiSelectOpen(type, keyWords) {
      if (type == this.dicType) {
        if (this.dicKeyWords == keyWords && this.mulitChoiceShow) {
          return true;
        }
        return false;
      }
    },
    pickerConfirm(e) {
      this.baseInfo.caseDate =
        e.year +
        "-" +
        e.month +
        "-" +
        e.day +
        " " +
        e.hour +
        ":" +
        e.minute +
        ":" +
        e.second;
    },
    selectCaseDate() {
      this.showPickerYear = true;
    },
    handlerChoosePerson(psrList) {
      let names = [];
      let ids = [];
      psrList.forEach((p) => {
        names.push(p.name);
        ids.push(p.id);
      });
      if (this.checkOrUnderTaker) {
        this.baseInfo.undertakerUuid = ids.join(",");
        this.baseInfo.undertaker = names.join(",");
      } else {
        if (psrList.length < 2) {
          this.$u.toast("案审员至少2人");
          return;
        } else {
          this.baseInfo.checkerUuid = ids.join(",");
          this.baseInfo.checker = names.join(",");
        }
      }
      this.orgPersonSelectShow = false;
    },
    getLocation() {
      this.setRouteParam({ disable: false, step: "start" });
      this.$u.route("pages/commonPage/modifyLocationMap");
    },
    choiceCaseOfAction() {
      this.setRouteParam(this.baseInfo.casePropertyRelList || []);
      this.$u.route({
        url: "/pages/case/components/casePropertySelection",
        params: {
          handleProc: this.baseInfo.handleProc, // 获取案件类型
        },
      });
    },
    choiceChecker() {
      this.roleCodes = "s_ajsly_s,s_ajsly_x";
      this.checkOrUnderTaker = false;
      this.orgPersonSelectShow = true;
    },
    choiceUnderTaker() {
      this.roleCodes = "s_zmjcy_x,s_zmjcy_s";
      this.checkOrUnderTaker = true;
      this.orgPersonSelectShow = true;
    },
    getLegalPunishData(arr) {
      let punishArgume = [];
      let legalArgume = [];
      for (let i = 0; i < arr.length; i++) {
        if (arr[i].propertySmokeType == "01") {
          // 专卖案由
          punishArgume.push(arr[i].punishItem || "");
          legalArgume.push(arr[i].legalItem || "");
        } else {
          // 电子烟案由
          let xp = arr[i].smokeIllegalUuid
            ? arr[i].smokeIllegalUuid.split(",")
            : [];
          let eilist = arr[i].electricSmokeIllegalList.filter((it) => {
            return xp.includes(it.smokeIllegalUuid);
          });
          for (let j = 0; j < eilist.length; j++) {
            punishArgume.push(eilist[j].legalBasic || "");
            legalArgume.push(eilist[j].qualitativeBasic || "");
          }
        }
      }
      this.baseInfo.punishArgume = punishArgume.join(",");
      this.baseInfo.legalArgume = legalArgume.join(",");
    },
    updateBackState(param) {
      if (param.caseSelectionData) {
        // 案由选择回调
        let arr = [];
        let arrIds = [];
        param.caseSelectionData.map((itm) => {
          itm.caseUuid = this.baseInfo.caseUuid;
          arr.push(itm.caseProperty);
          arrIds.push(itm.casepropUuid);
        });
        this.isTransCase =
          arrIds.includes("1") ||
          arrIds.includes("2") ||
          arrIds.includes("3") ||
          arrIds.includes("27");
        this.baseInfo.casePropertyRelList = param.caseSelectionData;
        this.getLegalPunishData(param.caseSelectionData);
        this.baseInfo.caseOfAction = arr.join("、");
      } else if (param.pos) {
        //  定位
        // 回显经纬度
        this.baseInfo.placeGis = `${param.pos.longitude},${param.pos.latitude}`;
        this.baseInfo.placeGisX = param.pos.longitude;
        this.baseInfo.placeGisY = param.pos.latitude;
        let addressName = param.pos.regeocode.addressComponent;
        console.log("===" + JSON.stringify(param.pos));
        let area = commonService.getLocalName(
          addressName.province,
          addressName.city,
          addressName.district
        );
        let market = param.pos.regeocode.pois[0];
        if (this.$modal.isMuniCity(area.proCode)) {
          this.areaCoinNames = area.admdivName + area.areaName;
        } else {
          this.areaCoinNames = area.proName + area.admdivName + area.areaName;
        }
        this.baseInfo.placeStreet =
          addressName.township + addressName.street + addressName.streetNumber;
        this.baseInfo.placeProvCode = area.proCode;
        this.baseInfo.placeCityCode = area.admdivCode;
        this.baseInfo.placeCountyCode = area.countryCode;
        this.baseInfo.marketName =
          param.pos.regeocode.aois.length != 0
            ? param.pos.regeocode.aois[0].name
            : param.pos.regeocode.crosses.length != 0
            ? addressName.township + param.pos.regeocode.crosses[0].second_name
            : addressName.township;
      } else if (param["specialAction"]) {
        // 选择专项行动
        let actionObj = param["specialAction"][0];
        // 专项行动赋值
        this.baseInfo.actionUuid = actionObj.actionUuid;
        this.baseInfo.actionResultName = actionObj.actionName;
        this.$set(
          this.baseInfo,
          "actionResultName",
          this.baseInfo.actionResultName
        );
      }
    },
    searchData(txt) {
      return new Promise((resolve, reject) => {
        commonService
          .queryAreaBaseList(txt)
          .then((res) => {
            if (res.success) {
              let tmp = res.data;
              tmp.forEach((itm) => {
                itm.name = [itm.proname, itm.admdivname, itm.countryname].join(
                  ""
                );
                itm.id = uuidv4();
              });
              console.log("===" + JSON.stringify(tmp));
              resolve(tmp);
            } else {
              resolve([]);
            }
          })
          .catch((err) => {
            resolve([]);
          });
      });
    },
    choiceAutoItem(itm, index) {
      if (index == "1") {
        if (this.$modal.isMuniCity(itm.procode)) {
          this.baseInfo.caseFrom = [itm.admdivname, itm.countryname].join("");
        } else {
          this.baseInfo.caseFrom = [
            itm.proname,
            itm.admdivname,
            itm.countryname,
          ].join("");
        }
        this.baseInfo.fromProvCode = itm.procode;
        this.baseInfo.fromCityCode = itm.admdivcode;
        this.baseInfo.fromCountyCode = itm.countrycode;
      } else if (index == "2") {
        if (this.$modal.isMuniCity(itm.procode)) {
          this.baseInfo.caseTo = [itm.admdivname, itm.countryname].join("");
        } else {
          this.baseInfo.caseTo = [
            itm.proname,
            itm.admdivname,
            itm.countryname,
          ].join("");
        }
        this.baseInfo.toProvCode = itm.procode;
        this.baseInfo.toCityCode = itm.admdivCode;
        this.baseInfo.toCountyCode = itm.countryCode;
      }
    },
    nativeNameSelectShowComfir(areas) {
      if (this.$modal.isMuniCity(areas[0].proCode)) {
        this.areaCoinNames = [areas[0].admdivName, areas[0].countryName].join(
          ""
        );
      } else {
        this.areaCoinNames = [
          areas[0].proName,
          areas[0].admdivName,
          areas[0].countryName,
        ].join("");
      }
      this.baseInfo.placeProvCode = areas[0].proCode;
      this.baseInfo.placeCityCode = areas[0].admdivCode;
      this.baseInfo.placeCountyCode = areas[0].countryCode;
      this.nativeNameSelectShow = false;
    },
    submit() {
      this.$refs.uForm.validate((valid) => {
        if (!valid) return;
        this.$modal.showLoading("正在保存...");
        this.baseInfo.casePlace =
          this.areaCoinNames + this.baseInfo.placeStreet;
        caseService
          .saveCaseBaseInfo(this.baseInfo)
          .then((res) => {
            this.$modal.hideLoading();
            if (res.success) {
              this.backPrev({
                paramKey: "baseInfo",
                param: true,
              });
            } else {
              this.$modal.alert("保存失败:" + res.msg);
            }
          })
          .catch((err) => {
            this.$modal.hideLoading();
            this.$modal.alert("保存失败:" + err);
          });
      });
    },
    actionChange(val) {
      if (!val) {
        this.baseInfo.actionResultName = null;
        this.baseInfo.actionUuid = null;
      }
    },
    // 关联专项行动
    addActionRelation() {
      if (this.baseInfo.caseDate) {
        this.$u.route(
          "/pages/check/specialActionRelationList?caseDate=" +
            this.baseInfo.caseDate
        );
      } else {
        this.$u.toast("请选择案发时间!");
        return;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
@import "../case_common.scss";
.page {
  padding: 0;
}
.content {
  padding: 0 $cm-content-paddng-row 80px;
}

.title-select-tip {
  color: #c0c4cc;
}

.secion-title {
  font-size: 0.9rem;
  font-weight: 500;
  padding: 20rpx 0px 20rpx;
}

.flat-btn {
  position: fixed;
  bottom: 50rpx;
  margin: auto;
  left: 60rpx;
  right: 60rpx;
  z-index: 88;
}

.market_cs {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
}
.tp-class {
  width: 100%;
}
</style>
